<?php

namespace app\http\api\controller;

use app\http\api\service\AnalysisService;
use Carbon\Carbon;
use DI\Attribute\Inject;
use support\Request;
use support\Response;

/**
 * @desc    销售数据采集流水
 * @author  OverMiracle
 * @date    2024-02-15
 */
class Analysis
{
    #[Inject]
    protected AnalysisService $analysisService;

    public function index(Request $request): Response
    {
        $today = Carbon::today();
        $data = [
            'begin_date' => $request->post('begin_date', $today->format('Y-m-d 00:00:00')),
            'end_date'   => $request->post('end_date', $today->format('Y-m-d 23:59:59')),
            'start'      => $request->post('start', 0),
            'length'     => $request->post('length', 10),
            'orgz_id'    => $request->post('orgz_id', 0),
        ];
        return json($this->analysisService->getList($data));
    }
}